<?php

class SecurityIpController extends BaseController
{
	
	//安全管理，设置访问IP
	public function actionAdmin()
	{
		$model = Setting::model()->findByAttributes(array('zkl_variable'=>'security_ip'));
		if(empty($model)){
			$model = new Setting();
			$model->zkl_title = '访问后台安全IP';
			$model->zkl_variable = 'security_ip';
		}
		
		if(isset($_POST['Setting'])){
			$model->attributes = $_POST['Setting'];
			$ip = $_POST['ip'];
			foreach($ip as $val){
				$ipdata[] = join('.',$val);
			}
			$model->zkl_valued = serialize($ipdata);
			if($model->save()){
				//成功跳转
				$this->render('../index/success',array('message'=>'恭喜，安全IP设置成功'));
				exit;
			}
		}
		$this->render('admin',array(
			'model'=>$model,		
		));
	}

	// Uncomment the following methods and override them if needed
	/*
	public function filters()
	{
		// return the filter configuration for this controller, e.g.:
		return array(
			'inlineFilterName',
			array(
				'class'=>'path.to.FilterClass',
				'propertyName'=>'propertyValue',
			),
		);
	}

	public function actions()
	{
		// return external action classes, e.g.:
		return array(
			'action1'=>'path.to.ActionClass',
			'action2'=>array(
				'class'=>'path.to.AnotherActionClass',
				'propertyName'=>'propertyValue',
			),
		);
	}
	*/
}